2 <TITLE>Ordered hashing: insertion
7 <A HREF="../../images/handbook.gif"><IMG SRC="../../images/handbook2.gif" align=left></A>
8 <A HREF="../../hbook.html">
9 <IMG SRC="../../images/home_g.gif" hspace = 15 vspace = 4></A><BR>
10 <A HREF="../../expand.html">
11 <IMG SRC="../../images/contents_g.gif" hspace = 15 vspace = 4></A><BR>
12 <A HREF="../../search_a.html">
13 <IMG SRC="../../images/chapter_g.gif" hspace = 15 vspace = 4></A><BR>
14 <A HREF="311.ins.c.html"><IMG SRC="../../images/prevalg_g.gif" hspace = 15 vspace = 4></A><BR>
15 <A HREF="311c.srch.c.html">
16 <IMG SRC="../../images/nextalg_g.gif" hspace = 15 vspace = 4></A><BR>
19 <H2><B>Ordered hashing: insertion
28 procedure insert( key : typekey; var r : dataarray );
33 if n>=m then Error {*** table is full ***}
35 i := hashfunction( key ) ;
36 while (not empty(r[i])) and (not deleted(r[i]))
37 and (r[i].k<>key) do begin
38 if r[i].k > key then begin
39 {*** Exchange key and continue ***}
40 temp := key; key := r[i].k; r[i].k := temp
42 i := (i+increment(key)) mod m
44 if empty(r[i]) or deleted(r[i]) then begin
45 {*** do insertion ***}
49 else Error {*** key already in table ***}
52 </XMP></TD></TR></TABLE>
54 <H3><A HREF="ftp://sunsite.dcc.uchile.cl/pub/users/rbaeza/handbook/algs/3/337.ins.p"><IMG SRC="../../images/ftp.xbm" hspace=10>Pascal</A> source (337.ins.p) </H3></CENTER>
56 <IMG SRC="../../images/aw3.gif" align=left><H5><BR>
57 © <A HREF="http://aw.com">Addison-Wesley </A>Publishing Co. Inc.